package org.farm.framework.exception.handler;

import lombok.extern.slf4j.Slf4j;
import org.farm.common.response.Result;
import org.farm.common.response.enums.ResultCodeEnums;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author Frank Zou
 * @version v0.0.1
 * @date 2025/4/22
 * @description
 */
@Slf4j
@RestControllerAdvice(basePackages = "org.farm")
public class GlobalExceptionHandler {


    @ExceptionHandler(Exception.class)
    public Result<Void> handleException(Exception e) {
        log.error(e.getMessage(), e);
        return Result.fail(ResultCodeEnums.SYSTEM_ERROR, e.getMessage());
    }

}
